package com.king.config;

import com.king.im.handler.IMMsgHandlerFactory;
import com.king.im.server.IMServerStarter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
@Slf4j
public class IMServerConfig {

    @Value("${im.server.port}")
    private int port;

    @Bean
    IMServerStarter imServerStarter(){

        try {
            IMServerStarter serverStarter = new IMServerStarter(port);
            serverStarter.start();// 启动tio服务

            IMMsgHandlerFactory.init(); // 初始化消息处理器类别

        } catch (IOException e) {
            log.error("tio server 启动失败！",e);
        }




        return  null;
    }

}
